#!/bin/bash
#
# After the user authenticates the installation process, the InstallationCheck script is executed. 
# This script checks the target platform to see if it has the requirements necessary to support the payload.
#
# arguments and environmental variables.
#
#    tmpfile="/tmp/userprofile"
#    `defaults write "$tmpfile" UserLanguage $lang`


declare -a languages
languages=`defaults read ~/Library/Preferences/.GlobalPreferences AppleLanguages | tr -d '[()\n "]' | tr '[,]' '[ ]'`
declare -a current_locale
current_locale=`defaults read ~/Library/Preferences/.GlobalPreferences AppleLocale`

lang=`echo $languages | awk '{print $1}'`
UserLanguage=""
if [ x$lang = x"zh-Hans" ] && [ x$current_locale = x"zh_CN" ];then
    UserLanguage=$lang
elif [ x$lang = x"zh-Hans" ] && [ x$current_locale != x"zh_CN" ];then
    UserLanguage="en"
else
    UserLanguage=$lang
fi

if [ -s /tmp/userprofile ];then
    rm -f /tmp/userprofile
fi
tmpfile="/tmp/userprofile"
echo `defaults write "$tmpfile" UserLanguage $UserLanguage`
echo `defaults write "$tmpfile" UserHomeDir $HOME`

exit 0

